/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.losalpes.catalogo.servicios.mdb;

import com.losalpes.catalogo.servicios.areas.MercadeoRemote;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJB;
import javax.ejb.MessageDriven;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

/**
 *
 * @author am.ocampo256
 */
@MessageDriven(mappedName = "jms/promocionesTopic", activationConfig =  {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
        @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
        @ActivationConfigProperty(propertyName = "clientId", propertyValue = "MercadeoMDBBean"),
        @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "MercadeoMDBBean")
    })
public class MercadeoMDBBean implements MessageListener {

    @EJB
    private MercadeoRemote mercadeo;
    
    public MercadeoMDBBean() {
    }

    public void onMessage(Message message) {
        MapMessage mapMessage = null;
        try {
            if (message instanceof MapMessage) {
                mapMessage = (MapMessage) message;
                mercadeo.printLogMessage((String) mapMessage.getObject("mueble_referencia"), (String) mapMessage.getObject("mueble_nombre"));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
    
}
